import { onPointClick, initCanvas, drawPoints, clearCanvas, drawFn2 } from "../gui/draw";
import { IPoint } from "../models/gui";
import { getCentripetalFn } from "./centripetal";
import { getChordalFn, getChordalQuadSplineFn } from "./chordal";
import { getEquidistantFn } from "./equidistant";

export function hw3 () {
  const canvas: HTMLCanvasElement = document.querySelector('#canvas');
  initCanvas(canvas);
  const points: IPoint[] = [];
  const render = () => {
    clearCanvas(canvas);
    if (points.length > 1) {
      // const result1 = getEquidistantFn(points, 20);
      // const result2 = getChordalFn(points);
      // const result3 = getCentripetalFn(points);
      const result4 = getChordalQuadSplineFn(points);
      // drawFn2(canvas, result1.fn, result1.start, result1.end, 2, 'blue');
      // drawFn2(canvas, result2.fn, result2.start, result2.end, 4, 'green');
      // drawFn2(canvas, result3.fn, result3.start, result3.end, 2, 'brown');
      drawFn2(canvas, result4.fn, result4.start, result4.end, 2, 'rebeccapurple');
    }
    drawPoints(canvas, points, 'red');
  }
  onPointClick(canvas, (p) => {
    points.push(p);
    render();    
  });
  
}

